package org.dallasrowing.logbook.ui.controller;

import java.util.List;

import org.dallasrowing.logbook.ui.view.BeanEditorWidget;
import org.dallasrowing.model.Boat;
import org.dallasrowing.model.dao.BoatsDAO;
import org.dallasrowing.model.dao.DAOException;

public class BoatEditorControllerImpl extends BeanEditorControllerImpl<Boat> {

	private BoatsDAO boatsDao;

	public BoatEditorControllerImpl(AdminWindowController parentController,
			BeanEditorWidget<Boat> widget, BoatsDAO boatsDao) {
		super(parentController, widget);
		this.boatsDao = boatsDao;
		init();
	}

	@Override
	protected void createBean(Boat bean) throws DAOException {
		boatsDao.createNewBoat(bean);
	}

	@Override
	protected List<Boat> getAllBeans() throws DAOException {
		return boatsDao.allBoats(true);
	}

	@Override
	protected Boat newBean() throws DAOException {
		return new Boat();
	}

	@Override
	protected void updateBean(Boat bean) throws DAOException {
		boatsDao.updateBoat(bean);
	}

}
